#include "../src/ControlCollege.hpp"
#include "../src/CameraDriver/DaHeng/Driver.hpp"
#include "../src/FileFormat/OriginImg.hpp"

#include <unistd.h>
#include <iostream>

ControlCollege con;

int main()
{
  con<<dynamic_cast<BaseDriver*>(new DahengDriver);
  con.funcCameraOffline=[](std::string uuid){
    std::cout<<uuid<<" 相机已下线";
  };
  con.funcMsg=[](std::string msg)
  {
    std::cout<<"获取到消息: "<<msg<<std::endl;
  };
  con.Boot();
  std::string DEVUUID;
  bool enableDevTest=false;
  con.AppendFileFormat<OriginImg>("OriginImg");
  {
    std::cout<<">>>>>> 获取所有设备"<<std::endl;
    auto listdev=con.GetAllDevice();
    std::cout<<"相机设备总数: "<<listdev.size()<<std::endl;
    for(const auto &i : listdev)
        std::cout<<i<<std::endl;
    if(listdev.size()>0)
    {
      DEVUUID=*listdev.begin();
      enableDevTest=true;
    }
    std::cout<<"<<<<<< 获取所有设备"<<std::endl<<std::endl;
  }

  if(enableDevTest)
  {
    std::cout<<">>>>>> 设备配置测试"<<std::endl;
    std::cout<<con.GetSettingList(DEVUUID)<<std::endl;
    std::cout<<"<<<<<< 设备配置测试"<<std::endl<<std::endl;
    std::cout<<">>>>>> 拍摄测试"<<std::endl;
    std::cout<<"After-ShotStatus: "<<con.ShotStatus(DEVUUID)<<std::endl;
    std::cout<<"After-RecordStatus: "<<con.RecordStatus(DEVUUID)<<std::endl;
    con.StartShot(DEVUUID);
    con.StartRecord(DEVUUID,"/tmp/CAMERA_RECORD_TEST",0);
    sleep(10);
    std::cout<<"Doing-ShotStatus: "<<con.ShotStatus(DEVUUID)<<std::endl;
    std::cout<<"Doing-RecordStatus: "<<con.RecordStatus(DEVUUID)<<std::endl;
    sleep(10);
    con.StopRecord(DEVUUID);
    con.StopShot(DEVUUID);
    std::cout<<"<<<<<< 拍摄测试"<<std::endl;
  }

  {
    std::cout<<">>>>>> 获取所有文件格式"<<std::endl;
    auto listformat=con.GetAllFormat();
    for(const auto & i : listformat)
        std::cout<<i<<std::endl;
    std::cout<<"<<<<<< 获取所有文件格式"<<std::endl;
  }

  return 0;
}
